<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><script type="text/javascript" src="/utils/scripts/flat-ui.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><link rel="shortcut icon" href="/utils/image/favicon.ico" type="image/x-icon" />
<meta charset="UTF-8">
<title>学生信息管理系统</title>
<!-- Loading Bootstrap -->
<link href="/utils/css/vendor/bootstrap.min.css" rel="stylesheet">
<!-- Loading Flat UI Pro -->
<link href="/utils/css/flat-ui.css" rel="stylesheet">
<!-- Loading Flat UI JS -->
<script type="text/javascript" src="/utils/scripts/flat-ui.min.js"></script>
<script type='text/javascript' src='/utils/scripts/particles.js'></script><link href="/utils/css/animate.css" rel="stylesheet"></head>

<body><div id="particles-js"><canvas class="particles-js-canvas-el" width="1322" height="774" style="width: 100%; height: 100%;"></canvas></div>
	<jsp:include page="adminLeft.jsp" />
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<h5>添加学生</h5>
				<form action="/studentServlet.do?flag=addStudent" method="post" name="form1">
					<div class="row">
						<div class="col-md-6">
							<h6>学号</h6>
							<input type="text" name="sid" id="sid" class="form-control" oninput = "value=value.replace(/[^\d]/g,'')" maxlength="12"></input>
							<span id="countsid" style="color: #ff0000;"></span>
							<h6>姓名</h6>
							<input type="text" name="sname" class="form-control" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')" maxlength="4"></input>
							<h6>身份证号</h6>
							<input type="text" name="sidcard" class="form-control" oninput = "value=value.replace(/[^\d]/g,'')" maxlength="16"></input>
							<h6>性别</h6>

							<label class="radio" for="radio1"> <input type="radio"
								name="ssex" value="男" id="radio1" data-toggle="radio"
								class="custom-radio"> <span class="icons"> <span
									class="icon-unchecked"></span> <span class="icon-checked"></span>
							</span> <font style="vertical-align: inherit;"> <font
									style="vertical-align: inherit;"> 男 </font>
							</font>
							</label> <label class="radio" for="radio2"> <input type="radio"
								name="ssex" value="女" id="radio2" data-toggle="radio"
								class="custom-radio"> <span class="icons"> <span
									class="icon-unchecked"></span> <span class="icon-checked"></span>
							</span> <font style="vertical-align: inherit;"> <font
									style="vertical-align: inherit;"> 女 </font>
							</font>
							</label>

							<h6>密&nbsp;&nbsp;码</h6>
							<input type="password" name="spassword" class="form-control" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');" maxlength="16"/>
						</div>
						<div class="col-md-6">
							<h6>年龄</h6>
							<input type="text" name="sage" class="form-control" maxlength="2"></input>
							
							
							<h6>学院</h6>
							<select name="profession"
								class="form-control select select-primary select-block mbl" id="belongcoll">
								<option value="-1">-请选择学院-</option>
							</select>
							
							<h6>专业</h6>
							<select name="college"
								class="form-control select select-primary select-block mbl" id="belongpro">
								<option value="-1">-请选择专业-</option>
							</select>
							
							<h6>班级</h6>
							<select name="classr"
								class="form-control select select-primary select-block mbl" id="belongcla">
								<option value="-1">-请选择班级-</option>
							</select>
							
						</div>
						<div class="col-md-12">
							<br> <input type="submit"
								class="btn btn-primary btn-wide login-btn" value="添加" />
						</div>
					</div>
				</form>

			</div>
		</div>
	</div>

<script type="text/javascript" src="/utils/scripts/flat-ui.js"></script><script src="/utils/scripts/bganimation.js"></script>
<script src="/utils/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
	$(function () {
		$.get(
				"/collegeServlet.do?flag=getColleges",
				function (result) {
					const colleage = JSON.parse(result);
					colleage.forEach(item=>{
						$('<option />',{text: item.title , value: item.id}).appendTo($("#belongcoll"))
						// getPro()
					})
				}
		)

		$("#belongcoll").click(function () {
			// $("#belongpro").empty()
			$("#belongpro").find('option').remove()

			var majorid= $("#belongcoll").val();
			if (majorid==-1){
				$('<option />',{text :"-请选择专业(test)-",value: -1}).appendTo($("#belongpro"))
				getclass(-1)
				return
			}
			$.get(
					"/majorServlet.do?flag=getMajors&collegeId="+majorid+"",
					function (result) {
						const  major= JSON.parse(result);
						major.forEach(item =>{
							$('<option/>',{text: item.mname, value: item.id}).appendTo($("#belongpro"))
						})
						majorid= $("#belongpro").val();
						getclass(majorid)
					}
			)

		})
		$("#belongcla").click(function () {
			// $("#belongcla").find('option').remove()
			$("#belongcla").empty()

			var majorid= $("#belongpro").val();
			// $("#belongcla").empty()
			if (majorid==-1){
				$('<option/>',{text :"-请选择班级(test)-",value: -1}).appendTo($("#belongcla"))
				return
			}

			$.get(
					"/ClassMonmentController.do?flag=findclass&majorid="+majorid+"",
					function (result) {
						// alert(result)
						const res =JSON.parse(result);
						res.forEach(item =>{
							$('<option/>',{text:item.classname,value:item.id}).appendTo($("#belongcla"))
						})
					}
			)
		})
	})

</script>


<%--</script>--%>
<%--&lt;%&ndash;	<script>&ndash;%&gt;--%>
<%--&lt;%&ndash;		$("select").select2({&ndash;%&gt;--%>
<%--&lt;%&ndash;			dropdownCssClass : 'dropdown-inverse'&ndash;%&gt;--%>
<%--&lt;%&ndash;		});&ndash;%&gt;--%>
<%--	</script>--%>
</body>
</html>